package event.money.tracker;

import MTClient.ClientLogic;
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class AddProduct extends Activity {
	
	private Integer eventID = null;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	
	    setContentView(R.layout.add_product);
	    
	    eventID = getIntent().getExtras().getInt("eventID");
	    
	    Button CancelBTN =(Button)findViewById(R.id.ProductCancelBTN);
	    CancelBTN.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				setResult(RESULT_OK);
		    	finish();
			}
		});
	    
	    Button SubmitBTN =(Button)findViewById(R.id.ProductSubmitBTN);
	    SubmitBTN.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {

				// get values
				String aProductName = ((EditText)findViewById(R.id.AddProductName)).getText().toString();
				String aDescription = ((EditText)findViewById(R.id.ProductDescr)).getText().toString();
				String aPrice = ((EditText)findViewById(R.id.ProductPrice)).getText().toString();

				// local update only, so can return here
	            ClientLogic.GetInstance().AddProduct(eventID.toString(), aProductName, aDescription, aPrice, "", "");
	            
	            setResult(RESULT_OK);
		    	finish();
			}
		});
	}

}
